
from rest_framework.views import exception_handler as drf_exception_handler
from rest_framework.response import Response

# 导入日志模块
from utils import my_logging
logger = my_logging.get_logger()

# 重写异常处理函数
def exception_handler(exc, context):
    response=drf_exception_handler(exc,context)
    if response is None:
        response = Response({'code':999,'msg':'服务器异常，请重试'})
    else:
        response = Response({'code':998,'msg':response.data['detail']})
    logger.critical('%s' % exc)
    return response













